/*global pi, self, importScripts */
self.onmessage = function (e) {
	"use strict";
	var data = e.data;

	//导入pi_mod.js
	importScripts(data.modPath);
	//设置模块配置，必须为pi.mod.list()
	pi.mod.config(data.modConfig);
	//加载需要运行模块，将该模块上面的onMessage设置到worker上
	pi.mod.require([data.runMod], function () {
		var i, n, r, arr;
		// 循环设置pi的模块，支持多层嵌套模块
		arr = data.runMod.split(".");
		for (i = 0, n = arr.length, r = self; i < n; i++) {
			r = r[arr[i]];
		}
		self.onmessage = r.onmessage;
	});
};